//
//  HDSwitchSettingVC.m
//  HDSmartPenSDKDemo
//
//  Created by 牛的mini on 2016/12/26.
//  Copyright © 2016年 牛的mini. All rights reserved.
//

#import "HDSwitchSettingVC.h"

@interface HDSwitchSettingVC ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, strong) NSArray *dataArray;
@property (nonatomic, strong) NSArray *statusArray;
@property (weak, nonatomic) IBOutlet UITableView *myTableView;

@end

@implementation HDSwitchSettingVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"硬件信息";
    
    _myTableView.dataSource = self;
    _myTableView.delegate = self;
    _myTableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    _myTableView.rowHeight = 50.0f;
    _dataArray = @[@"MP3音频播放",@"RFID",@"红外",@"蓝牙",@"防盗报警"];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(reloadStatusAction:)
                                                 name:kBeacon_SMPen_Part_Info_Notification
                                               object:nil];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [[HDBeaconManager sharedBeacon] readAllInfoAction];
    [LCCoolHUD showLoading:@"正在获取" inView:self.view];
}

- (void)reloadStatusAction:(NSNotification *)noti
{
    NSArray *statusArray = noti.object;
    if (statusArray.count > 0)
    {
        _statusArray = statusArray;
        [_myTableView reloadData];
    }
    [LCCoolHUD hideInView:self.view];
}

- (NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{ return _dataArray.count; }

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifeir = @"HDSwitchSettingVCCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifeir];
    
    NSInteger nowRow = indexPath.row;
    cell.textLabel.text = _dataArray[nowRow];
    
    UISwitch *nowSwitch = [UISwitch new];
    nowSwitch.tag      = nowRow+100;
    [nowSwitch setOn:NO];
    [nowSwitch setUserInteractionEnabled:NO];
    if (_statusArray.count > nowRow)
    {
        NSString *str = _statusArray[nowRow];
        if (str.integerValue == 1)
            [nowSwitch setOn:YES];
    }
    
    cell.accessoryView = nowSwitch;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}

- (void)switchChangeAction:(UISwitch *)sender
{
    NSInteger nowTag = sender.tag;
    switch (nowTag) {
        case 100:
            break;
           
        case 101:
            break;
            
        case 102:
            break;
            
        case 103:
            break;
            
        case 104:
            break;
            
        case 105:
            break;
            
        case 106:
            break;
            
        default:
            break;
    }
}

- (void)dealloc
{}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
